package 实例信息;

interface HasBatteries {
}

interface Waterproof {
};

interface shoots {
};

class Toy {
	public Toy() {
	}

	Toy(int i) {
	}
}

class FancyToy extends Toy implements HasBatteries, shoots, Waterproof {

}

public class ToyTest {
	static void printInfo(Class cc) {
		System.out.println("class name:" + cc.getName());
		System.out.println("class is interface: [" + cc.getInterfaces() + "]");
		System.out.println("simple name:" + cc.getSimpleName());
		System.out.println("canonical name:" + cc.getCanonicalName());
	}

	public static void main(String[] args) {
		Class c = null;
		try {
			c = Class.forName("实例信息.FancyToy");

		} catch (ClassNotFoundException e) {
			System.out.println("can not found fancyTory");
			e.printStackTrace();
			System.exit(1);
		}
		printInfo(c);

		for (Class anInterface : c.getInterfaces()) {
			//printInfo(anInterface);
		}
		Class up = c.getSuperclass();
		Object obj = null;
		try {
			obj = up.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
			System.out.println("cannot instantiate");
			System.exit(1);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
			System.exit(1);
		}
		printInfo(obj.getClass());

	}
}
